package 一些算法竞赛测试题;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-10-13
 * Time: 15:50
 */
public class Demo12 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[][] q = new int[n + 1][n + 1];
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= i; j++){
                q[i][j] = scan.nextInt();
            }
        }
        for(int i = 2; i <= n; i++){
            for(int j = 1; j <= i; j++){
                q[i][j] = Math.max(q[i - 1][j - 1], q[i - 1][j]) + q[i][j];
            }
        }
        if(n % 2 == 0){
            System.out.println(Math.max(q[n][n / 2], q[n][n / 2 + 1]));
        }else{
            System.out.println(q[n][n / 2 + 1]);
        }
    }
}
